package com.sky.config;

import com.aliyun.oss.internal.OSSUtils;
import com.sky.properties.AliOssProperties;
import com.sky.utils.AliOssUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @Date 2025/10/9 21:40
 * @description: 初始化oss对象
 * .
 * @Author LittleNight
 */

@Component
@Slf4j
public class OssClientConfig {


    @Bean
    @ConditionalOnMissingBean // 保证唯一
    public AliOssUtil createOSSUtils(AliOssProperties aliOssProperties) {
        log.info("开始创建阿里云文件上传工具类对象: {}", aliOssProperties);
        return new AliOssUtil(aliOssProperties.getAccessKeyId()
                ,aliOssProperties.getBucketName()
                , aliOssProperties.getBucketName()
                , aliOssProperties.getAccessKeySecret());
    }
}
